﻿#include <iostream>
#include <vector>

using namespace std;

// 应用IIR滤波器
vector<double> apply_iir_filter(const vector<double>& signal, const vector<double>& b_coefficients, const vector<double>& a_coefficients) {
    int N = signal.size();
    vector<double> filtered_signal(N, 0.0);

    for (int n = 0; n < N; ++n) {
        for (int i = 0; i < b_coefficients.size(); ++i) {
            if (n - i >= 0) {
                filtered_signal[n] += b_coefficients[i] * signal[n - i];
            }
        }
        for (int j = 1; j < a_coefficients.size(); ++j) {
            if (n - j >= 0) {
                filtered_signal[n] -= a_coefficients[j] * filtered_signal[n - j];
            }
        }
    }

    return filtered_signal;
}